home *** CD-ROM | disk | FTP | other *** search
- Path: hilbert.dnai.com!usenet
- From: Victor Bazarov <vbazarov@imsisoft.com>
- Newsgroups: comp.lang.c
- Subject: Re: C type question
- Date: Mon, 05 Feb 1996 11:45:28 -0800
- Organization: IMSI
- Message-ID: <31165E58.104B@imsisoft.com>
- References: <Pine.SUN.3.91.960202131027.20090A-100000@sun19.cs.cuhk.hk>
- NNTP-Posting-Host: 204.182.61.84
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (Win95; I)
-
- Cheung ming wai wrote:
- >
- > Hi,
- >
- > I've some problems about my following program:
- > The program should be run under PC.
- > =========
- > /* program to find the smallest +ve number */
- > #include <stdio.h>
- >
- > main(void)
- > {
- > long double u, v;
- > u = v = 0.5;
- > while((1+u) > 1) {
- > v = u;
- > u /= 2;
- > }
- > printf("The smallest number (1+u)>1 is: %e.\n", v);
-
- The problem is that some compilers expect "%le" for double values.
- Their printf accepts %e, %f, or %g as formats for float values, not
- double. So try %le.
-
- > return 0;
- > }
- > ================
- > The result output is somewhat not true!? 4.???e-3XX
- >
- > But if I use C++ cout as output, the ans is 4.????e-19
- >
- > Do I get something wrong in the printf()?
- > What is the argument used for long double? %e? %g? %lf?
-
- Victor.
-